{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css"/>
<script src="__JS__/zepto.min.js"></script>
<script src="__JS__/lrz.min.js"></script>
<style>

    .form-head{
        color: white;
        font-size: 16px;
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 5px;
        overflow: hidden;
        padding-top:10px;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-repeat:no-repeat;
        background-size:cover;
        text-align: center;
        background-attachment:fixed;
    }
    .body-input{
        outline: none;
        color: #dddddd;
        position: relative;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0);
        float: left;
        margin: auto;
        font-size: 16px;
        height: 41px;
        line-height: 41px;
        border-radius: 5px;
        width: 60%;
        font-family: "Microsoft YaHei UI";
    }
    .bottom-btn{
        width:100%;
        height:100%;
        float: left;
    }
    button{
        border: none;
        color:white;
    }
    .botton1{
        background-color: #FF0000;
    }
    .botton2{
        background-color: #00a0e9;
    }
    .input-window{
        margin-left: auto;
        margin-right: auto;
        background-color: rgba(255,255,255, 0.8);
        background-color: white;
        height:90px;
        width:90px;
        border-radius: 10px;
        margin-top: 30px;
    }
    .aa{
        height:3px;
        background-color: white;
        width:40px;
        position:absolute;
        top: 30px;
        left:55px;
    }
    .bb{
        width: 100%;
        height: 100%;
        opacity: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
</style>
{/block}
{block name="body"}

<form action="{:url('login/register')}" method="post" style="width:95%;margin: auto">
    <div class="form-head" style="height:300px;margin-top:10px;">
        <input class="form-input3-input" id="seller_id" name="seller_id" type="hidden" value="{$seller_id}" placeholder=" ">
        <div class="form-input3" >
            <label for="title" class="form-input3-label">标题:</label>
            <input style="" class="form-input3-input" id="title" name="title" type="text" value="{$detail['title']|default=''}" placeholder=" ">
        </div>
        <div class="form-input3" style="height:170px">
            <label for="detail" class="form-input3-label" >内容:</label>
            <textarea class="body-input" name="detail" id="detail" type="text"  style="height:160px;line-height: 30px;" rows="50" cols="3">{$detail['detail']|default=''}</textarea>
            <!--<input class="body-input" name="sex" id="sex" type="text" value="" style="height:160px;line-height: 30px;">-->
        </div>



    </div>
    <!--<div class="form-body">-->
        <!--<div class="input-window" style="background-image: url(__IMG__/1313.png);background-size: cover">-->

            <!--<input class="bb headimgurl" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />-->
            <!--<input  type="hidden" id="img" value="0" />-->
        <!--</div>-->
    <!--</div>-->
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
            <div class="weui_uploader">
                <div class="weui_uploader_hd weui_cell">
                    <div class="weui_cell_ft"></div>
                </div>
                <div class="weui_uploader_bd">
                    <ul class="weui_uploader_files" id='img2'>
                        {neq name="img" value=""}
                        {volist name="img" id="vo"}
                        <li  data-id="{$vo}" class="delmy weui_uploader_file weui_uploader_status" style="background-image:url(__BASE__/index.php/picture/index?id={$vo})">
                            <div class="weui_uploader_status_content"><i class="weui_icon_cancel"></i></div>
                        </li>
                        {/volist}
                        {/neq}

                    </ul>
                    <div class="weui_uploader_input_wrp" id="file2">
                        <input class="weui_uploader_input" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"  id='headimgurl' multiple />
                        {volist name="img" id="vo"}
                        <input id="{$vo}" value="{$vo}"  type="hidden" name="files" />
                        {/volist}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div style="position:fixed;bottom:0;left:0;width:100%;height:50px;">
        <button id="submit" class="bottom-btn botton2" type="button">提交</button>
    </div>

</form>
{/block}
{block name="footer"}
<script type="text/javascript" src="__JS__/public.js"></script>
<script>

    $("#img2").on("click",".delmy",function(){
        var delimg=$(this);
        var inputid = '#'+$(this).data("id");
        $.confirm('您确定要删除吗?', '确认删除?', function() {delimg.remove();$(inputid).remove()},function(){$.toast('取消操作', 'cancel');});
    });


    $(function(){

        $('#headimgurl').change(function () {
            var v_this = $(this);
            lrz(this.files[0],{width:640,fieldName:"image"}).then(function (rst) {
                var formdata = new FormData();
              //  v_this.parent().css("background-image","url("+rst.base64+")");//无论是否上传成功都显示
                url = getBaseUrl()+"web.php/file/upload_picture_base64";
                formdata.append("image", rst.base64);
                $.ajax({
                    url : url,
                    type : 'post',
                    data : formdata,
                    contentType : false,
                    processData : false,
                    dataType : "json",
                    success : function(data) {
                        if (data.status == true) {
                            $('#img2').append('<li  data-id="'+data.info[0]['id']+'" class="delmy weui_uploader_file weui_uploader_status" style="background-image:url('+rst.base64+')"><div class="weui_uploader_status_content"><i class="weui_icon_cancel"></i></div></li>');
                            $('#file2').append('<input id="'+data.info[0]['id']+'" value="'+data.info[0]['id']+'"  type="hidden" name="files" />');
                        }
                    },
                    error:function(){
                        $.toast("图片上传失败");
                    }
                });
                return false;
            })
        });
    });
    var img = '';
    $('#submit').click(function () {
        $("input[name='files']").each(function(){
            img += ','+$(this).val();
        });

            var body  ={
                seller_id:$('#seller_id').val(),
                title:$('#title').val(),
                detail:$('#detail').val(),
                img:img.substr(1)
            };
            var $this = $(this);
            $this.addClass('weui-btn_disabled').attr('disabled','disabled');
            ajax_post(getBaseUrl()+'web.php/extension/shopdetail_edit',jQuery.param(body),{
                success:function(data){
                    $.toast("编辑成功",'success');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                   setTimeout(
                        function(){
                            history.back(-1);
                        }
                        ,1500);
                },
                error:function(data){
                    $.toptip('编辑失败', 'error');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                }
            })


    });
</script>
{/block}